Release 10.1A: OpenEdge Development:
ADM and SmartObjects


Initializing the foreign key fields

ForeignFields is a SmartDataObject property that is set at design time to designate which of its fields to map to foreign key fields in a SmartDataObject that is its parent. A corresponding property called ForeignValues holds the values of those fields for the current row. When ForeignFields is set for a particular SmartDataObject, performing the Add or Copy operation in that SmartDataObject assigns the values of the key fields to the corresponding fields in the newly added row.

Suppose you have two SmartDataObjects, CUST and ORDER, that are set up as follows:

Figure 4–1 illustrates this setup.

Figure 4–1: Inheriting foreign key field values

As the application user adds orders, the value of the ORDER SmartDataObject’s cust-num field is automatically set to the current value of the CUST SmartDataObject’s cust-num field; that is, 27. This is done in the addRow function of data.p to display the ForeignField value as the initial value for the new row. If the application user does not change that value (and such fields normally cannot be updated), the initial value is assigned to the new row in the procedure submitForeignField, called from the function submitRow during the Save operation. See the online help for descriptions of these functions,


Copyright © 2005 Progress Software Corporation
www.progress.com
Voice: (781) 280-4000
Fax: (781) 280-4095